#include <stdio.h>

#include "../utils/astr.h"
#include "../utils/csv.h"
#include "../utils/array.h"
#include "../utils/log.h"

int main()
{
    FILE *fp = fopen("test.log", "w");
    log_add_fp(fp, "test");
    array_t *csv_root = csv_parse_file("nba.csv");

    char *data[] = {"lql", "china long", "100", ":SG", "18", "600.0", "super", "", ""};
    csv_array_add_line(csv_root, data, 9);
    for (size_t i = 0; i < csv_root->len; i++)
    {
        printf("line:%ld ==>", i);
        array_t *csv_line = array_get(csv_root, i);
        for (size_t j = 0; j < csv_line->len; j++)
        {
            astr_t *str = array_get(csv_line, j);
            printf(" [%ld]: %s ", j, str->data);
        }
        printf("\n");
    }

    csv_file_rewrite("nba3.csv", csv_root);
    fclose(fp);
    csv_free(&csv_root);
}